<?php
/**
 * Created by PhpStorm.
 * User: zsd
 * Date: 2016/12/1
 * Time: 13:55
 * Email:zsd_it@163.com
 *
 * 测试 处理
 */
namespace App\Http\Controllers;

use Cache;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redis as Redis;
use DB;

class TestController extends Controller{

    /**
     * 测试 Redis
     */
    public function redis(){

        echo '<h1>测试Redis</h1>';

        $key = 'user:name:6';

        $user = array(
                'id'    => 1,
                'name'  =>  '张三',
        );
        if($user){
            //将用户名存储到Redis中
            Redis::set($key,$user['name']);
        }

        //判断指定键是否存在
        if(!Redis::exists($key)){
            //根据键名获取键值
            dd('nothing');
        }

        echo Redis::get($key);


        var_dump(Cache::put('bb','艹你大爷',20));
        var_dump( Cache::get('bb'));

    }

    /**
     * insert listing resource
     */
    public function index(){

        //DB::insert('insert into `users` (id,name,email,password) values(?,?,?,?)',[2, 'Laravel','laravel@test.com','123']);
        //DB::insert('insert into `users` (id,name,email,password) values(?,?,?,?)',[3, 'Academy','academy@test.com','123']);



    }

    /**
     * display listing resource
     */
    public function select(){

//        $list   =   DB::select('select  * from users where id= ?',[1]);

//        $list   =   DB::table('users')->where('id','>','1')->get();
        $list   =   DB::table('users')
//            ->join('users_info','users.id','=','users_info.uid')
//            ->leftJoin('users_info','users.id','=','users_info.uid')
            ->rightJoin('users_info','users.id','=','users_info.uid')
            ->skip(1)
            ->take(1)
            ->get();

        dd($list);

    }


    public function getRouteKeyName(){}

    /**
     * 发送 数据
     */
    public function email(){
        Mail::raw('这是一封测试邮件', function ($message) {
            $to = '897119946@qq.com';
            $message ->to($to)->subject('测试邮件');
        });
    }

}